import FilterCard from '@/pages/components/FilterCard/index';
import DataCard from './components/DataCard';
import TableCard from './components/TableCard';

import { VipTypeEnum, vipLabelMap } from '@/enums/vip.enum';

import type { FilterFormItemType, ValueType } from '@/pages/components/FilterCard/types/index.type';
import type { VipValueType } from '@/types/vip.type';

const OrderManage = () => {
  // 会员类型
  const vipTypeOptions = Object.keys(VipTypeEnum)
    .filter(key => /^\d+$/.test(key)) // 过滤掉非数字类型的 key
    .map(key => ({ value: +key, label: vipLabelMap[+key as VipValueType] }));

  const filterFormList: FilterFormItemType[] = [
    { label: '订单号', name: 'orderNumber', type: 'input' },
    { label: '联系电话', name: 'phoneNumber', type: 'input' },
    { label: '会员类型', name: 'vipType', type: 'select', options: vipTypeOptions },
    { label: '订单时间', name: 'openingTime', type: 'rangePicker' },
  ];
  const onFilterCardFinish = (value: ValueType) => {
    console.log('🚀 ~ onFinish ~ value:', value);
  };
  const onFilterCardReset = () => {
    console.log('🚀 ~ onReset');
  };

  return (
    <div>
      <DataCard />
      <FilterCard filterFormList={filterFormList} onFinish={onFilterCardFinish} onReset={onFilterCardReset} />
      <TableCard />
    </div>
  );
};
export default OrderManage;
